package logic

import (
	"context"
	"video-up-manager/models/mysql"

	"video-up-manager/videorpc/internal/svc"
	"video-up-manager/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentReplyLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentReplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentReplyLogic {
	return &CommentReplyLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CommentReplyLogic) CommentReply(in *videorpc.CommentReplyRequest) (*videorpc.CommentReplyResponse, error) {
	// todo: add your logic here and delete this line

	var comment mysql.Comment

	comment = mysql.Comment{
		VideoId:        in.ReplyId,
		UserId:         in.ReplyId,
		CommentContent: in.CommentContent,
		IsAnonymous:    in.IsAnonymous,
		CommentTime:    in.CommentTime,
		CommentStatus:  in.CommentStatus,
		ReplyId:        in.ReplyId,
	}
	if err := comment.CommentReply(mysql.DB); err != nil {
		return nil, err
	}

	return &videorpc.CommentReplyResponse{
		CommentId: int64(comment.ID),
	}, nil
}
